package put.cs.two.to.tsp.calculators.base;

import put.cs.two.to.tsp.models.NodeSet;
import put.cs.two.to.tsp.models.Point;

public class AbstractCalculator {

    protected NodeSet tmpInputNodes = new NodeSet();

    protected Point getNearestPoint(Point contextPoint) {
        int minDistance = Integer.MAX_VALUE;
        Point nearest = null;
        for (Point point : tmpInputNodes.getUnusedPoints()) {
            if (NodeSet.getDistance(contextPoint, point) < minDistance) {
                minDistance = NodeSet.getDistance(contextPoint, point);
                nearest = point;
            }
        }
        return nearest;
    }
}
